from dataclasses import dataclass
from flask import Blueprint, Flask
from injector import inject

from handler import AppHandler, AppTestHandler


@inject
@dataclass
class Router():
    app_handler: AppHandler
    app_test_handler: AppTestHandler

    def register_router(self, app: Flask):
        bp = Blueprint('llmops', __name__, url_prefix='/api')
        bp.add_url_rule('/ping', view_func=self.app_handler.hello_world)
        bp.add_url_rule('/chat', view_func=self.app_handler.chat, methods=['POST'])
        bp.add_url_rule('/app', view_func=self.app_handler.create_app, methods=['POST'])
        bp.add_url_rule('/app/<uuid:id>', view_func=self.app_handler.get_app)
        bp.add_url_rule('/test_message', view_func=self.app_test_handler.promit_message)
        bp.add_url_rule('/test_template', view_func=self.app_test_handler.message_template)

        app.register_blueprint(bp)
